using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;

using Coding4Fun.FakeCall.Data;

namespace Coding4Fun.FakeCall.Controls
{
	public class CallingUserControl : UserControl
	{
		public CallingUserControl()
		{
			DataContext = this;
			Settings = FakeCallSettings.Instance;
		}

		private FakeCallSettings _settings;
		public FakeCallSettings Settings
		{
			get { return _settings; }
			set
			{
				_settings = value;
				RaisePropertyChanged("Settings");
			}
		}

		#region INotifyPropertyChanged Members

		public event PropertyChangedEventHandler PropertyChanged;

		protected void RaisePropertyChanged(string propertyName)
		{
			if (PropertyChanged != null)
			{
				PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}
		#endregion

		internal void EndCall(RoutedEventArgs e)
		{
			InvokeCallEnded(e);
		}

		public event RoutedEventHandler CallEnded;

		public void InvokeCallEnded(RoutedEventArgs e)
		{
			var handler = CallEnded;
			if (handler != null) 
				handler(this, e);
		}
	}
}